﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Docking="clr-namespace:Monti.Docking">

   <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="/Monti;component/Themes/Common.xaml" />
   </ResourceDictionary.MergedDictionaries>

   <Style x:Key="TabItemFocusVisual">
      <Setter Property="Control.Template">
         <Setter.Value>
            <ControlTemplate>
               <Rectangle Stroke="#555" StrokeDashArray="1 2" 
                          StrokeThickness="1" Margin="0,8,3,6" 
                          SnapsToDevicePixels="true"/>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="{x:Type Docking:DockContent}">
      <Setter Property="IsSelected"
              Value="{Binding Path=IsSelected}" />
      <Setter Property="IsEnabled"
              Value="{Binding Path=IsEnabled}" />
      <Setter Property="ToolTip"
              Value="{Binding Path=ToolTip}" />
      <Setter Property="AllowClose"
              Value="{Binding Path=AllowClose}" />
      <Setter Property="Header"
              Value="{Binding Path=Title}" />
      <Setter Property="IsActiveContent"
              Value="{Binding Path=IsActiveContent, Mode=TwoWay}" />
      <Setter Property="IsTabStop"
              Value="False" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type Docking:DockContent}">
               <Grid Height="30"
                     Focusable="False">
                  <Border Focusable="False"
                          Name="Border"
                          Background="{StaticResource MetroBaseBackground}"
                          Margin="0,4,0,0"
                          BorderThickness="0" 
                          CornerRadius="3,3,0,0">
                     <Grid Focusable="False">
                        <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="Auto"/>
                           <ColumnDefinition Width="*"/>
                           <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        
                        <ContentPresenter Content="{TemplateBinding Icon}" 
                                          HorizontalAlignment="Center" 
                                          Grid.Column="0"
                                          Focusable="False"
                                          VerticalAlignment="Center"/>
                        
                        <TextBlock Grid.Column="1"
                                   Focusable="False"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Margin="7,2,12,2"
                                   Name="HeaderText"
                                   TextTrimming="CharacterEllipsis"
                                   Text="{TemplateBinding Header}"/>
                        <!--<ContentPresenter x:Name="ContentSite"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Center"
                                          ContentSource="Header"
                                          Grid.Column="1"
                                          Focusable="False"
                                          RecognizesAccessKey="False"/>-->

                        <Button x:Name="PART_CloseButton"
                                Focusable="False"
                                IsTabStop="False"
                                ToolTip="Close"
                                Style="{StaticResource TabItemCloseButtonStyle}"
                                Command="{Binding Path=CloseCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Docking:DockManager}}}"
                                CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Docking:DockContent}}}"
                                Grid.Column="2"
                                Margin="-7,5,7,5"/>
                     </Grid>
                  </Border>
               </Grid>
               <ControlTemplate.Triggers>
                  
                  <!-- The appearance of a TabItem when it's inactive/unselected -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="Border.IsMouseOver" Value="False"/>
                        <Condition Property="IsSelected" Value="False"/>
                     </MultiTrigger.Conditions>
                     <Setter Property="Panel.ZIndex" Value="90" />
                     <Setter TargetName="Border" Property="Background" 
                                Value="#EBEBEB" />
                  </MultiTrigger>

                  <!-- 
                        The appearance of a TabItem when it's disabled 
                        (in addition to Selected=False)
                     -->
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Panel.ZIndex" Value="80" />
                     <Setter Property="Foreground" 
                                Value="{StaticResource MetroDisabledText}" />
                  </Trigger>

                  <!-- The appearance of a TabItem when the mouse hovers over it -->
                  <MultiTrigger>
                     <MultiTrigger.Conditions>
                        <Condition Property="Border.IsMouseOver" Value="True"/>
                        <Condition Property="IsSelected" Value="False"/>
                     </MultiTrigger.Conditions>
                     <Setter Property="Panel.ZIndex" Value="99" />
                     <Setter Property="Background" TargetName="Border"
                             Value="#D8D8D9"/>
                  </MultiTrigger>

                  <!-- The appearance of a TabItem when it's active/selected -->
                  <Trigger Property="IsSelected" Value="True">
                     <!-- We want the selected TabItem to always be on top. -->
                     <Setter Property="Panel.ZIndex" Value="100" />
                     <Setter TargetName="Border" Property="Background" 
                             Value="#D8D8D9" />
                  </Trigger><!-- #3A87AD, lighter  #4AADDB  -->

                  <Trigger Property="AllowClose"
                           Value="false">
                     <Setter Property="Visibility"
                             Value="Collapsed"
                             TargetName="PART_CloseButton" />
                  </Trigger>
                  
                  <Trigger Property="IsActiveContent"
                           Value="True">
                     <Setter TargetName="Border"
                             Property="Background"
                             Value="#3A87AD" />
                     <Setter Property="Foreground"
                             Value="White"/>
                  </Trigger>

                  <DataTrigger Binding="{Binding Path=IsToolWindow, 
                     RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Docking:DockSite}}}"
                               Value="True">
                     <Setter TargetName="Border"
                             Property="CornerRadius"
                             Value="0,0,3,3" />
                     <Setter TargetName="Border"
                             Property="BorderThickness"
                             Value="1,0,1,1" />
                     <Setter TargetName="Border"
                             Property="Margin"
                             Value="0,0,0,4" />
                     <Setter TargetName="PART_CloseButton"
                             Property="Visibility"
                             Value="Collapsed" />
                  </DataTrigger>
                  
                  <MultiDataTrigger>
                     <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Path=IsToolWindow, 
                     RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Docking:DockSite}}}"
                                   Value="True" />
                        <Condition Binding="{Binding Path=IsSelected}"
                                   Value="False" />
                     </MultiDataTrigger.Conditions>
                     <Setter TargetName="Border"
                             Property="BorderThickness"
                             Value="1,1,1,1" />
                  </MultiDataTrigger>

               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   
</ResourceDictionary>